package com.itgungnir.diyshuo.fragment.zhinan_fragment;

import com.itgungnir.diyshuo.bean.DiyBean;
import com.itgungnir.diyshuo.bean.GoodsBean;
import com.itgungnir.diyshuo.http.HttpHelper;
import com.itgungnir.diyshuo.http.ListHelper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import rx.Observable;
import rx.Subscriber;
import rx.internal.util.ObserverSubscriber;

/**
 * Created by ITGungnir on 2016/10/5.
 */

public class ZhinanPresenter implements ZhinanContract.Presenter{
    private ZhinanModel model;
    private ZhinanContract.View view;

    public ZhinanPresenter(ZhinanContract.View view) {
        this.view = view;
        this.model=new ZhinanModel();
    }

    @Override
    public void getZhinanFromNet() {
        //mobile=no&version=4&module=forumdisplay&fid=2&page=1
        Map<String,String> map=new HashMap<>();
        map.put("mobile","no");
        map.put("version","4");
        map.put("module","forumdisplay");
        map.put("fid","2");
        map.put("page","1");
        model.getZhinanData(map, new ZhinanContract.OnLoadNewsListener() {
            @Override
            public void onSuccess(DiyBean bean,List<Integer> list) {
                List<GoodsBean> goodsBeanList=bean.getVariables().getForumThreadlist();
                view.onGetZhinanSuccess(goodsBeanList,list);
            }

            @Override
            public void onFailure(Exception e) {

            }
        });

    }
}
